# Makefile for lib
#
# $Id: Makefile,v 1.1.1.1 2003/01/21 21:23:07 root Exp $
#

include ../../Rules.mk

CACHEPROF = ../../Ccprof/cacheprof --cacheprofdir=../../Ccprof

OBJECTS = global_socket.o gmt2local.o

OBJ_PROFALL =   $(OBJECTS:.o=_profall.o)

INCLUDES = -I../../capture -I../../capture/libpcap-1.0.0 -I../user-tcp

SRCS = $(pathsubst %.o,%.c,$(OBJECTS))

# This is a bit ugly, but it's convenient to have a single place where 
# tracing levels are defined for all source files. Format of each entry here
# is <file base>.<trace level>
# Trace levels: 0 = none; 1 = assert; 2 = error; 3 = warn; 4 = all
#TRC = socketcall.3 hash.3 trace.3 lowlevel.3 tcp_signals.3 skbuff.3
TRC = socketcall.3 hash.3 trace.3 tcp_signals.3 skbuff.3

all: simple

simple: $(OBJECTS)
	ar -ru ../../lib/libusernet.a $(OBJECTS)

prof: $(OBJECTS)
	ar -ru ../../lib/libusernet_prof.a $(OBJECTS)

profall: $(OBJ_PROFALL)
	ar -ru ../../lib/libusernet_profall.a $(OBJ_PROFALL)

complete: $(OBJECTS)
	ar -ru ../../lib/libiscsi.a $(OBJECTS)

clean:
	rm -f *.o *.a *~ sta* core

# Even more ugly -- we have to go round the houses to extract the correct
# trace-level digit from the TRC variable :-(
%.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@ \
        -DTRACE_LEVEL=$(patsubst .%,%,$(suffix $(filter $(<:.c=)%,$(TRC))))

%_profall.o : %.c
	$(CACHEPROF) $(CC) $(CFLAGS) -c $< -o $@ \
        -DTRACE_LEVEL=$(patsubst .%,%,$(suffix $(filter $(<:.c=)%,$(TRC))))

depend:
	cd test; $(MAKE) depend; cd ..;
	makedepend $(PROF) $(DEBUG) $(INCLUDES) $(SRCS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
